package ui;
import java.awt.Container;
import java.awt.Image;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
 

import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPasswordField;
import javax.swing.JTextField;
 
/**
 * 浠縌Q鐧诲綍鐣岄潰
 * 
 * @author Ben
 */
public class GUIQQ extends JFrame {
    // 鐢ㄦ埛鍚�
    private JTextField username;
    
	// 瀵嗙爜
    private JPasswordField password;
    private String runame;
    private String rpassword;
    // 灏忓鍣�
    private JLabel jltop;
    private JLabel jl1;
    private JLabel jl2;
    private JLabel jl3;
    private JLabel jl4;
 
    // 灏忔寜閽�
    private JButton bu1;
    
 
    /*
     * 鏋勯�犳柟娉�
     */
    public GUIQQ() {
        // 璁剧疆绐楀彛鏍囬
        this.setTitle("QQ2018轻聊版");
        // 绐椾綋缁勪欢鍒濆鍖�
        init();
        this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        // 璁剧疆甯冨眬鏂瑰紡涓虹粷瀵瑰畾浣�
        this.setLayout(null);
         
        this.setBounds(0, 0, 435, 354);
        // 璁剧疆绐椾綋鐨勬爣棰樺浘鏍�
        Image image = new ImageIcon("e:/a.gif").getImage();
        this.setIconImage(image);
         
        // 绐椾綋澶у皬涓嶈兘鏀瑰彉
        this.setResizable(false);
         
        // 灞呬腑鏄剧ず
        this.setLocationRelativeTo(null);
 
        // 绐椾綋鍙
        this.setVisible(true);
    }
 
    /*
     * 鍒濆鍖栨柟娉�
     */
    public void init() {
        // 鍒涘缓涓�涓鍣�
        Container con = this.getContentPane();
        jltop= new JLabel();
        jl1 = new JLabel();
        // 璁剧疆鑳屾櫙鍥剧墖
        ImageIcon image1 = new ImageIcon(this.getClass().getResource("/top1.jpg"));
        jltop.setIcon(image1);
        jltop.setBounds(0, 0, 430, 162);
        
        jl1.setBounds(0,182,430,150);
        // QQ鐧诲綍澶村儚璁惧畾
        jl2 = new JLabel();
        ImageIcon image2 = new ImageIcon(this.getClass().getResource("/touxiang.jpg"));
        jl2.setIcon(image2);
        jl2.setBounds(40, 14, 80, 80);
 
        // 鐢ㄦ埛鍙风爜鐧诲綍杈撳叆妗�
        username = new JTextField();
        username.setBounds(136, 197, 190, 20);
        // 鐢ㄦ埛鍙风爜鐧诲綍杈撳叆妗嗘梺杈圭殑鏂囧瓧
        jl3 = new JLabel("");
        jl3.setBounds(340, 15, 70, 20);
 
        // 瀵嗙爜杈撳叆妗�
        password = new JPasswordField();
        password.setBounds(136, 225, 190, 20);
        // 瀵嗙爜杈撳叆妗嗘梺杈圭殑鏂囧瓧
        jl4 = new JLabel("");
        jl4.setBounds(340, 40, 70, 20);
 
        
 
       
        // 鎸夐挳璁惧畾
        ImageIcon img = new ImageIcon(this.getClass().getResource("/login1.jpg"));
        bu1 = new JButton(img);
        bu1.setBounds(135, 70, 190, 25);
        // 缁欐寜閽坊鍔�1涓簨浠�
        bu1.addActionListener(new ActionListener() {
             
            public void actionPerformed(ActionEvent e) {
                String str=e.getActionCommand();
                          String getName =username.getText();
                    setRuname(getName);
                    String getPwd =password.getText();
                    setRpassword(getPwd);
                    username.setText("");
                    password.setText("");
//                  System.out.println(getName);
                }
            
        });
         
       
        // 鎵�鏈夌粍浠剁敤瀹瑰櫒瑁呰浇
        jl1.add(jl2);
        jl1.add(jl3);
        jl1.add(jl4);
        jl1.add(bu1);
       
        con.add(jltop);
        con.add(jl1);
        con.add(username);
        con.add(password);
        
        
 
    }
 
   

	public String getRuname() {
		return runame;
	}

	public void setRuname(String runame) {
		this.runame = runame;
	}

	public String getRpassword() {
		return rpassword;
	}

	public void setRpassword(String rpassword) {
		this.rpassword = rpassword;
	}
	
	public static void main(String[] args) {
	        // 瀹炰緥鍖栧璞�
			boolean islogin=true;
	        GUIQQ qq = new GUIQQ();
	        //鍦ㄨ繖閲屽悜鏈嶅姟鍣ㄥ彂鏍￠獙淇℃伅锛屾垚鍔熺殑璇濆垎閰嶇嚎绋嬶紝涓嶆垚鍔熺户缁彁绀虹櫥褰曞け璐ワ紝閲嶆柊杈撳叆
//			qq.setVisible(false);
//			System.out.println("鍚姩鍙﹀涓�涓狫frame");
	        
	        System.out.println(qq.getRuname());
	        
	    }
}
